//cookie
const express = require('express');
const cookieParser = require( 'cookie-parser' );
var server = express();

//cookie
server.use( cookieParser('abcdefg') );
server.use('/',function(req,res){
    req.secret = 'abcdefg';// 秘钥  signed签名
    res.cookie('user','zhangsan',{path:'/aaa',maxAge:30*24*3600*1000,signed:true});  // 发送cookie
    console.log( req.cookies );  // 读取无签名的cookie
    console.log( req.signedCookies );  // 读取签名的cookie
    res.send('ok');
});

server.use('/del',function(req,res){
    res.clearCookie('user');
    console.log( req.signedCookies );  
    res.send('已删除');
});

server.listen(8080);